using Game.Const;
using Game.Core;
using Game.Main.Model;
using Game.Main.View;
using Game.Manager;
using UnityEngine;

namespace Game.Component
{
	public class GemBoxItem : BaseItem
	{
		private int clickNum;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
		}

		public override void QuicklyTouch(TouchEventData touchEventData)
		{
			base.QuicklyTouch(touchEventData);
			if (base.itemData.createIds != null && archiveData.createIndexs.Count < base.itemData.createAmount)
			{
				int num = Random.Range(0, 100);
				if (num < 20 && clickNum >= 2)
				{
					clickNum = 0;
					Transform transform = model.Find("CreatePoint");
					BaseItem baseItem = Singleton<Scene>.Instance.CreateItem(base.itemData.createIds[Random.Range(0, base.itemData.createIds.Length)], transform.position, 0);
					if (baseItem != null)
					{
						AddCreateItem(baseItem);
						baseItem.DropDown(transform.position, true);
					}
					Singleton<AudioManager>.Instance.PlaySound("sound_explode");
					Singleton<EffectManager>.Instance.ShowEffect(PathConst.EFFECT + "efc_explode_1", baseItem.transform.position + new Vector3(0f, 0.2f, -0.0004f), 1f);
					Singleton<EffectManager>.Instance.ShowEffect(PathConst.EFFECT + "efc_blink_1", baseItem.transform.position + new Vector3(0f, 0f, -0.0004f), 3f);
				}
				else
				{
					clickNum++;
					Singleton<EffectManager>.Instance.ShowEffect(PathConst.EFFECT + base.itemData.effect, model.transform.position + new Vector3(0f, 0.3f, -0.0004f), 1f);
					Singleton<AudioManager>.Instance.PlaySound("sound_gem_box_1");
				}
			}
			else
			{
				Singleton<AudioManager>.Instance.PlaySound("sound_atm_error");
			}
		}
	}
}
